package com.hzhk.happyrent.ui.adapter.card;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.hzhk.happyrent.R;
import com.hzhk.happyrent.ui.holder.card.CardBankViewHolder;
import com.hzhk.happyrent.ui.holder.card.CardHeaderViewHolder;
import com.hzhk.happyrent.ui.holder.card.CardHotViewHolder;
import com.hzhk.happyrent.ui.holder.card.CardThemeViewHolder;
import com.hzhk.happyrent.ui.holder.rent.HomeHeaderViewHolder;
import com.hzhk.happyrent.utils.ToastUtil;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Created by soft_zzc on 2017/11/24.
 */

public class CardLoadAdapter extends BaseAdapter {

    private Logger log = LoggerFactory.getLogger(this.getClass().getName());

    boolean isFristInto = true ;

    public CardLoadAdapter(Context context) {
        log.debug("jump into CardLoadAdapter");
        this.context = context;
    }

    private Context context;
    private int count = 3;

    @Override
    public int getCount() {
        return count;
    }

    @Override
    public Object getItem(int i) {
        return i;
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        CardHeaderViewHolder cardHeaderViewHolder;
       // CardThemeViewHolder cardThemeViewHolder;
        CardHotViewHolder cardHotViewHolder;
        CardBankViewHolder cardBankViewHolder;
        if (convertView == null) {
            switch (position) {
                case 0:
                    log.debug("jump into case 0:");
                    convertView = LayoutInflater.from(context).inflate(
                            R.layout.fragment_rent_header, null);
                    cardHeaderViewHolder = new CardHeaderViewHolder(convertView, context);
                    convertView.setTag(cardHeaderViewHolder);
                    break;
              /*  case 1:
                    convertView = LayoutInflater.from(context).inflate(
                            R.layout.fragment_card_type, null);
                    cardThemeViewHolder = new CardThemeViewHolder(convertView, context);
                    //cardThemeViewHolder.setAction();
                    convertView.setTag(cardThemeViewHolder);
                    break;*/
                case 1:
                    log.debug("jump into case 1:");
                    convertView = LayoutInflater.from(context).inflate(
                            R.layout.fragment_card_hot, null);
                    cardHotViewHolder = new CardHotViewHolder(convertView, context);
                    //cardHotViewHolder.setAction();
                    convertView.setTag(cardHotViewHolder);
                    break;
                case 2:
                    log.debug("jump into case 2:");
                    convertView = LayoutInflater.from(context).inflate(
                            R.layout.fragment_bank_hot, null);
                    cardBankViewHolder = new CardBankViewHolder(convertView, context);
                    //cardBankViewHolder.setAction();
                    convertView.setTag(cardBankViewHolder);
                    break;
            }
        } else {
            switch (position) {
                case 0:
                    log.debug("jump into case 0:");
                    cardHeaderViewHolder = (CardHeaderViewHolder) convertView
                            .getTag();
                    //cardHeaderViewHolder.setData();
                    break;
             /*   case 1:
                    cardThemeViewHolder = (CardThemeViewHolder) convertView
                            .getTag();
                    //cardThemeViewHolder.setAction();
                    break;*/
                case 1:
                    log.debug("jump into case 1:");
                    cardHotViewHolder = (CardHotViewHolder) convertView
                            .getTag();
                    //cardHotViewHolder.initView();
                    break;
                case 2:
                    log.debug("jump into case 2:");
                    cardBankViewHolder = (CardBankViewHolder) convertView
                            .getTag();
                    //cardBankViewHolder.initView();
            }

        }
        return convertView;
    }

    @Override
    public int getItemViewType(int position) {
        return position;
    }

    @Override
    public int getViewTypeCount() {
        return 3;
    }

}
